داستان آبیدیک

class library


فارسی

1 کامپیوتر و شبکه:: class library

so let's just stop with the first Protein right here and that's going to be for the core entities because it's Just that simple so what I want to do is pretty much just Move the customer into its own project Instead of having that inside the UI project right here so I'm going to move This guy into a new project but since This is the first project that I want to Add I right-click right here I say add new project there we go I have to make a Choice right I can choose two different project types since this is not a UI Project I don't want to use any kind of console app or REST API or MVC application anything like that I'm just going to select something called a class library in the.net framework pretty much just a package now that package doesn't Know anything about user interfaces it doesn't know how to present the data to The user the idea with the class library Is just that it's a package that can handle some data work some data do something for you it's going to provide You some kind of infrastructure some kind of way to communicate with the Package an API a set of interfaces called what you want so you can kind of have a contract with this package and Say I want the customers here you go here's the customers whatever you want to do right so that's why we're going to use a class library but they're two Different ones we can pick now we can pick the class library that's built for dublin core very specifically for dotnet core and that gives you some pretty cool extension some pretty cool things you could do with the dotnet core framework but there's also another one called the dotnet standard library that's a multi-platform that's something that you can use in other frameworks you can use it for instance in dotnet core like we're doing sweet but in the old frameworks as well meaning that if you for some reason decide that you want to downgrade to the old framework you can Actually still use this core setup of the heart of our application right here inside the old frameworks as well now this is pretty amazing because that means that we could do the other way welcome back so now we have our interface the next step is going to be Creating the first infrastructure or the actual implementation on how we do all of this how do we create a customer how do we how do we read all our customers Back how do we actually work with data And that's the goal of this lesson right here we're going to start out by in the infrastructure folder right so if I go back to the drawing right here you'll Notice that now I'm going to start Working down here what we actually Implement our different information Right so now we've created this guy and we've made the interface for the domain service now we're going to try and use it and actually create something so that we can start working with data and Actually storing it let's just try and add a new project right here and let's Just create this time it's going to be dotnet specific okay so it's going to be Done at core specific sorry so what I'm going to do is I'm going to pick the Class library this time but notice I'm not picking the standard library it's the class library if you can't find that Going to dub net core library and there's the class library I'm going to Pick that one I'm going to say next going to keep that in a Core 2.1 next so I'm going to call this customer app infrastructure static data because this is going to contain a static list right later on I'll make a new one called data that we're going to build the realist curl solution in ok so now we have a new Project I'm going to add this and it's Inside infrastructure right here let's Just get rid of this class right here Just to that's just annoying there we go so now we have our new project right here and in there we're going to make a new folder right away so I'll add a new folder and that's going to be called the repositories because that's going to keep contain all repositories in my Solution now we only probably only going To end up with a customer for now but let's say you also had order lines whatever you had that's going to be available in here as well so now we have that access up and running as well and then what we can do is create our first Repository right here called customer repository so I'll just make a class Customer or a Parsi Tori there we go and notice this time that it's an empty class not an interface and it's called customer repository there we go let's Just keep the constructor for now one Very important thing is that right out of the box I'm going you just add i customer repository right here my customer notice I can't find it i customer repository now why can't I Find it you guys should know that now yes you're right of course I didn't add The dependency so I'll just edit reference or at dependencies and say I Need the core and I need the entity down here I need both of them because I need the core to kind of get the I repository and I need the entity to kind of get the customer entity right I'm going to need both there we go so now I can do a command dot and it'll pop up hopefully and tell me if I don't want to use the beautiful domain service right here there we go now that one is imported let's just get rid of the reusing for now we can import it again if we need it sweet it still complaints and that's because even though I call myself now I use the contract customer repository I haven't actually implemented the Functions that I need to call myself again remember this is a contract so to Be able to use the interface customer repository and call yourself a customer repository you need to have all these functions right so we need to now go from actually having an interface or a contract inter actually having an Implementation so you can right click Right here and do the quick fix if you want to and that should be pretty much the same thing with the command dot do you want to implement the interface and I'll say yes and boom I get all the Functions in here but notice they all Just throw an exception right now saying I'm not implemented I'm not implemented and neither am I blah so none of them are implemented let's just move move the delete one to the bottom so it's kind of the crud set up right here there we go so this was all I had to do now I've implemented my new customer Repository right but well I'm not quite there yet because I actually of course need to start implementing all of these different methods right it's not enough Just to have the repository but now it's available and we start using it later on sweet so how do we actually do this well we need to of course start looking into our program and since we're going to make a complete copy of what we already Have just in a new layer we need some kind of static list and a counter and stuff like that to kind of start working with our set up right here so let's just stop by coming these two guys and adding them inside our new repository because that is going to be the fake database for now right it's going to be a local list that represents a list of customers and some kind of ID that can count up right so it's still being a fake in-memory database that as soon as I restart the program it'll be reset kind of sucky but it's a way just to kind of explain to you guys how we can make our first customer repository with a fake data set later on we can easily change this and we will but for now let's just make it simple sweet next lesson what I want to do is I want to start adding these create read update and delete just like we have them over here in the program so I'll start using moving the storage of the domain logic on how to work and save these guys from the program and slowly start moving them into the repository so let's do that in the next lesson see you next time have fun.

واژگان شبکه مترجمین ایران


معنی‌های پیشنهادی کاربران

نام و نام خانوادگی
شماره تلفن همراه
متن معنی یا پیشنهاد شما
Captcha Code